/*
 * @(#) $Header$
 *
 * Copyright (C) 2013  Daniel Léonard
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package ca.forklabs.baselib.security;

import java.io.FileDescriptor;
import java.net.InetAddress;
import java.security.Permission;

/**
 * Class {@code AllowEverythingSecurityManager} is a security manager that
 * allows everything, no questions asked.
 *
 * @author   <a href="mailto:forklabs at gmail.com?subject=ca.forklabs.baselib.security.AllowEverythingSecurityManager">Daniel Léonard</a>
 * @version $Revision$
 */
public class AllowEverythingSecurityManager extends SecurityManager {

//---------------------------
// Constructors
//---------------------------

   /**
    * Constructor.
    * @throws   SecurityException   if the current security manager does not
    *                               allow new security managers.
    */
   public AllowEverythingSecurityManager() {
   // nothing
      }


//---------------------------
// Overridden methods from java.lang.SecurityManager
//---------------------------

   /**
    * Grants the permission.
    * @param   perm   ignored.
    */
   @Override
   public void checkPermission(Permission perm) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   perm   ignored.
    * @param   context   ignored.
    */
   @Override
   public void checkPermission(Permission perm, Object context) {
   // nothing
      }

   /**
    * Grants the permission.
    */
   @Override
   public void checkCreateClassLoader() {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   t   ignored.
    */
   @Override
   public void checkAccess(Thread t) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   g   ignored.
    */
   @Override
   public void checkAccess(ThreadGroup g) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   status   ignored.
    */
   @Override
   public void checkExit(int status) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   cmd   ignored.
    */
   @Override
   public void checkExec(String cmd) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   lib   ignored.
    */
   @Override
   public void checkLink(String lib) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   fd   ignored.
    */
   @Override
   public void checkRead(FileDescriptor fd) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   file   ignored.
    */
   @Override
   public void checkRead(String file) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   file   ignored.
    * @param   context   ignored.
    */
   @Override
   public void checkRead(String file, Object context) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   fd   ignored.
    */
   @Override
   public void checkWrite(FileDescriptor fd) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   file   ignored.
    */
   @Override
   public void checkWrite(String file) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   file   ignored.
    */
   @Override
   public void checkDelete(String file) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   host   ignored.
    * @param   port   ignored.
    */
   @Override
   public void checkConnect(String host, int port) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   host   ignored.
    * @param   port   ignored.
    * @param   context   ignored.
    */
   @Override
   public void checkConnect(String host, int port, Object context) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   port   ignored.
    */
   @Override
   public void checkListen(int port) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   host   ignored.
    * @param   port   ignored.
    */
   @Override
   public void checkAccept(String host, int port) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   maddr   ignored.
    */
   @Override
   public void checkMulticast(InetAddress maddr) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   maddr   ignored.
    * @param   ttl   ignored.
    */
   @Override
   public void checkMulticast(InetAddress maddr, byte ttl) {
   // nothing
      }

   /**
    * Grants the permission.
    */
   @Override
   public void checkPropertiesAccess() {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   key   ignored.
    */
   @Override
   public void checkPropertyAccess(String key) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   window   ignored.
    * @return    always {@code true}.
    */
   @Override
   public boolean checkTopLevelWindow(Object window) {
      return true;
      }

   /**
    * Grants the permission.
    */
   @Override
   public void checkPrintJobAccess() {
   // nothing
      }

   /**
    * Grants the permission.
    */
   @Override
   public void checkSystemClipboardAccess() {
   // nothing
      }

   /**
    * Grants the permission.
    */
   @Override
   public void checkAwtEventQueueAccess() {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   pkg   ignored.
    */
   @Override
   public void checkPackageAccess(String pkg) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   pkg   ignored.
    */
   @Override
   public void checkPackageDefinition(String pkg) {
   // nothing
      }

   /**
    * Grants the permission.
    */
   @Override
   public void checkSetFactory() {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   clazz   ignored.
    * @param   which   ignored.
    */
   @Override
   public void checkMemberAccess(Class<?> clazz, int which) {
   // nothing
      }

   /**
    * Grants the permission.
    * @param   target   ignored.
    */
   @Override
   public void checkSecurityAccess(String target) {
   // nothing
      }

   }
